package com.warningrc.system.data.dao;

import java.lang.reflect.ParameterizedType;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * 基础的Dao类，作为其他自定义Dao的根类
 * @author <a href="http://weibo.com/weibowarning">王宁</a>
 * @date 2011-12-30
 * @email <a href="mailto:childe.wangning@gmail.com">childe.wangning@gmail.com</a>
 * @param <T>
 */
public abstract class DaoSupport<T> extends HibernateDaoSupport {
	protected Class<T> entityClass;

	@SuppressWarnings("unchecked")
	public DaoSupport() {
		entityClass = (Class<T>) ((ParameterizedType) getClass()
				.getGenericSuperclass()).getActualTypeArguments()[0];
		if (entityClass.getName().startsWith("java"))
			throw new IllegalStateException("Generics type can't for "
					+ entityClass.getName() + "!");
	}
}
